package com.tanhua.model.vo;

import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.Video;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * @author Xiao
 * @version 1.0
 * @description 后台管理AdminVideoVO对象
 * @date 2021/11/2
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AdminVideoVO implements Serializable {
    private Long id; //编号
    private String nickname; //发布人昵称
    private Long userId;    //发布人id
    private Long createDate; //发布时间
    private String videoUrl; //视频URL
    private String picUrl; //封面URL
    private Integer likeCount; //点赞数量
    private Integer commentCount; //评论数量

    public static AdminVideoVO init(UserInfo userInfo, Video video) {
        AdminVideoVO adminVideoVO = new AdminVideoVO();
        //copy用户属性
        BeanUtils.copyProperties(userInfo,adminVideoVO);
        //copy视频属性
        BeanUtils.copyProperties(video,adminVideoVO);
        adminVideoVO.setCreateDate(video.getCreated());
        return adminVideoVO;
    }
}
